package sg.edu.nus.iss.phoenix.maintainusers.delegate;

import sg.edu.nus.iss.phoenix.authenticate.entity.Role;
import sg.edu.nus.iss.phoenix.authenticate.entity.User;
import sg.edu.nus.iss.phoenix.maintainusers.service.UserService;

import java.util.ArrayList;

/**
 * Created by A0119952X.
 */
public class UserDelegate {
    private UserService service;

    public UserDelegate() {
        super();
        service = new UserService();
    }

    /**
     * changePassword
     *
     * @param user
     * @return true or false
     */
    public boolean changePassword(User user) {
        return service.changePassword(user);
    }

    /**
     * find user by ID
     *
     * @param userId
     * @return User
     */
    public User findUserByUserId(String userId) {
        return service.getUserByLoginId(userId);
    }

    /**
     * get All Users
     *
     * @return all users
     */
    public ArrayList<User> findAllUser() {
        return service.getAllUsers();
    }

    /**
     * insert user
     *
     * @param user
     * @return true or false
     */
    public boolean insertUser(User user) {
        return service.addUser(user);
    }

    /**
     * update user
     *
     * @param user
     * @return true or false
     */
    public boolean updateUser(User user) {
        return service.updateUser(user);
    }

    /**
     * get all roles
     *
     * @return all roles
     */
    public ArrayList<Role> findAllRoles() {
        return service.getAllRoles();
    }

    /**
     * delete user
     *
     * @param user
     * @return true or false
     */
    public boolean deleteUser(User user) {
        return service.deleteUser(user);
    }
}
